//
//  MemberCallback.h
//  FlashAnimation
//
//  Created by chiawei.tseng on 13/1/2.
//
//

#ifndef CMemberCallback_h
#define CMemberCallback_h

#include "CCallBack.h"

template<typename T>
class CMemberCallback : public CCallBack
{
public:
    
    typedef void (T::*MemberCallbackFunctionPtr)(void*);
    
    CMemberCallback():CCallBack(),m_classPtr(0),m_memberCallbackFunctionPtr(0)
    {}
    
    CMemberCallback(T* classPtr,MemberCallbackFunctionPtr memberCallbackFunctionPtr):
    CCallBack(),m_classPtr(classPtr),m_memberCallbackFunctionPtr(memberCallbackFunctionPtr)
    {}
    
    ~CMemberCallback()
    {
    }
    
    void invoke(void* data)
    {
        if(m_memberCallbackFunctionPtr && m_classPtr)
        {
            (m_classPtr->*m_memberCallbackFunctionPtr)(data);
        }
    }
    
private:

    T* m_classPtr;
    
    MemberCallbackFunctionPtr m_memberCallbackFunctionPtr;
};
#endif
